[mirrors]
http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2
http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.bz2

[main]
filesize=22716802
sha512=5ec95ad47d49b12c4558a8db0ca2109d3ee1955e3776057f3330c4506f8f4d1cf5e505fbf8a16b98403a0fcdeaaf986fe0a22be6456247dbdace63ce1f776b12

[deps.host]
stage0_musl

[build]
patch -p1 < "$K"/binutils-arm.diff || exit 1
patch -p1 < "$K"/binutils-24-configure_ash.patch || exit 1

$K/bin/libibertyfix libiberty

[ "$STAGE" = "0" ] && CC="$butch_root_dir"/bin/musl-gcc

config_arch_flags=
if [ "$A" = "powerpc" ] ; then
        config_arch_flags="--enable-secureplt"
fi

LDFLAGS="-Wl,-static" \
CC="$CC -static" \
CFLAGS="-D_GNU_SOURCE -D_LARGEFILE64_SOURCE" \
./configure -C --prefix="$butch_prefix" \
  --disable-nls --disable-werror \
  --enable-initfini-array \
  --disable-install-libbfd $config_arch_flags || exit 1

make -j$MAKE_THREADS || exit 1
# tooldir=/
make DESTDIR=$butch_install_dir install-gas install-ld install-binutils || exit 1

dest="$butch_install_dir""$butch_prefix"
rm -f "$dest"/bin/ld
if [ x$A = xpowerpc ] ; then
	cat << EOF > "$dest"/bin/ld
#!/bin/sh
ld.bfd --secure-plt \$@
EOF
	chmod +x "$dest"/bin/ld
else
	ln -sf ld.bfd "$dest"/bin/ld
fi
